import { debounce } from '@/uni_modules/tuniaoui-vue3/utils/debounce';

const _mygo = (url: string, params?: Record<string, any>) => {
  let fullUrl = url;
  if (params && Object.keys(params).length) {
    const query = Object.entries(params)
      .map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(v)}`)
      .join('&');
    fullUrl += (url.includes('?') ? '&' : '?') + query;
  }
  uni.navigateTo({ url: fullUrl });
};

// 现在可以直接使用防抖函数了，因为参数传递已经修复
export const mygo = debounce(_mygo, 300);

